#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <cmath>
using namespace std;
int main() {
    int n, r;
    cin >> n >> r;
    int t = n;
    unordered_map<int, char> h;
    for(int i = 0; i < 21; i++) {
        if(i < 10) {
            h[i] = i + '0';
        }else {
            h[i] = i - 10 + 'A';
        }
    }
    string ret;
    while(n) {
        int temp = n % r;
        n /= r;
        if(temp < 0) {
            temp -= r;
            n++;
        }
        ret.push_back(h[temp]);
    }
    reverse(ret.begin(), ret.end());
    cout << t << "=" << ret << "(base" << r << ")" << endl;
    return 0;
}